<!DOCTYPE html>
<html lang="zh">

<head>
	<th:block th:include="include :: header('项目里程碑')" />
	<link href="../static/layui/css/layui.css" th:href="@{/layui/css/layui.css}" rel="stylesheet" />
	<link href="../static/layui/css/dropdown.css" th:href="@{/layui/css/dropdown.css}" rel="stylesheet" />
	<link href="../static/css/projectDetail.css" th:href="@{/css/projectDetail.css}" rel="stylesheet" />
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
	<!-- 头部导航 链接 -->
	<div class="row border-bottom white-bg dashboard-header headerNav">
		<div class="col-sm-1 logo">
			<div class="icon hidden-xs">
				<i class="fa fa-file-powerpoint-o"></i>
			</div>
			<div class="progressBar">
				<i>20.00%</i>
				<!-- style和 aria-valuenow里的数字代表进度 -->
				<div class="layui-progress" style="height: 5px;">
					<div class="layui-progress-bar " lay-percent="20.00%" style="width: 20%;"></div>
				</div>
			</div>
		</div>
		<div class="col-sm-11 navBar">
			<th:block th:include="include :: projectNavBar" />
		</div>
	</div>
	<!-- 主体部分 -->
	<div class="wrapper wrapper-content">
		<div class="btn-group-sm" id="toolbar" role="group">
			&nbsp;
        </div>
		<div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
	</div>
	<!-- import layui -->
	<th:block th:include="include :: footer" />
	<script th:src="@{/layui/dropdown.js?v=20250801}"></script>
	<th:block th:include="include :: projectDetail" />
	<!-- import layui -->
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('gcgl:milestone:edit')}]];
    	var removeFlag = [[${@permission.hasPermi('gcgl:milestone:remove')}]];
        var prefix = ctx + "sj/milestone";
        var datas = [[${@dict.getType('sj_milestone_status')}]];
        
        $(function() {
            var options = {
                url: prefix + "/p4list/"+$("#id").val(),
//                 createUrl: prefix + "/add/"+$("#id").val(),
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "项目里程碑",
//                 pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                queryParams: queryParams,
//                 sortName: "id desc",
//                 sortOrder: "",
                code: "id",
		        parentCode: "pId",
		        uniqueId: "id",
		        expandAll: false,
		        expandFirst: false,
		        columns: [{
                    field: 'selectItem', 
                    radio: false
                },
                {
                    field: 'orderNo',
                    title: '任务号',
                    width:'50'
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名称',
                    visible: false
                },
                {
                    field: 'name',
                    title: '任务名称',
                    width:'100'
                },
                {
                    field: 'owner',
                    title: '负责人',
                    width:'90'
                },
                {
                    field: 'pstartAt',
                    title: '计划开始',
                    width:'90'
                },
                {
                    field: 'pendAt',
                    title: '计划结束',
                    width:'90'
                },
                {
                    field: 'count',
                    title: '工作日',
                    width:'90'
                },
                {
                    field: 'jdbfb',
                    title: '进度百分比',
                    width:'90'
                },
                {
		            field: 'status',
		            title: '状态',
		            align: "left",
                    width:'90',
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.status);
		            }
		        },
                {
                    title: '操作',
                    align: "center",
                    width:'200',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.pId!=0){
                        	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        	actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        }else{
                        	actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="add4Jh(\'' + row.id + '\')"><i class="fa fa-edit"></i>添加计划</a> ');
                        	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="finish(\'' + row.id + '\')"><i class="fa fa-check"></i>完成</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="noFinish(\'' + row.id + '\')"><i class="fa fa-remove"></i>未完成</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.treeTable.init(options);
        });
        
        function queryParams(params){
        	var search = $.treeTable.queryParams(params);
        	search.gcProjectid = $("#id").val();
        	return search;
        }
        
        function add4Jh(id){
			$.modal.openTab('添加计划',"/sj/milestone/add4Jh/"+id);
	    }
        
        function finish(id){
        	$.modal.confirm("确认要修改状态完成吗?", function() {
	    		$.ajax({
    				url: "/sj/milestone/finish",
    				type: "post",
    				data: { "ids": id },
    				dataType: 'json',
    				success: function(data) {
    					$.treeTable.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.treeTable.refresh();
    				}
    			});
	    	});
        }
        
		function noFinish(id){
			$.modal.confirm("确认要修改状态未完成吗?", function() {
	    		$.ajax({
    				url: "/sj/milestone/noFinish",
    				type: "post",
    				data: { "ids": id },
    				dataType: 'json',
    				success: function(data) {
    					$.treeTable.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.treeTable.refresh();
    				}
    			});
	    	});
        }
    </script>
    <!--选中导航 这段js放在每个页面末尾-->
    <script>
		$(()=>{
			setTimeout(()=>{
				selectedNav(1)//第N个被选中 0即
			},100)
		})
		
		function selectedNav(index){
			$('ul.layui-nav').find('.layui-nav-item').eq(index).addClass('layui-this');
		}
	</script>
</body>
</html>